<link href="<?php echo base_url()?>common/css/public.css" rel="stylesheet" type="text/css">
<link rel="stylesheet" href="<?php echo base_url()?>common/kindeditor/themes/default/default.css" />
<script type="text/javascript" src="<?php echo base_url()?>common/js/jquery.min.js"></script>
<script type="text/javascript" src="<?php echo base_url()?>common/layer/layer.js"></script>
<script type="text/javascript">
    $(function () {
        $("input:checkbox").click(function () {
            var $this = $(this);
            if ($(this).prop("checked")) {
                add_goods_size($(this).val());
            }
            else {
                layer.confirm("取消该尺寸，将删除改尺寸对应的所有商品库存，确定执行该操作？", function (index) {
                    del_goods_size($this.val());
                    layer.close(index);
                }, function () {
                    $this.prop("checked", "checked");
                    layer.msg('取消删除', { icon: 0 });
                })
               
            }
        });
    });
    function Success(data) {
        parent.Success(data);

    }
    function add_goods_size(size_id) {
        var url = "/admin/goods/addgoods_size";
        var goods_id="<?php echo $goodsid?>";
        $.post(url, { "sizeid": size_id, "goodsid": goods_id }, function (data) {
            var jsonData = $.parseJSON(data);
            if (jsonData.Statu == 'ok') {
                Success(jsonData)
            }
            else {
                Success(jsonData)
            }
        })
    }

    function del_goods_size(size_id) {
        var url = "/admin/goods/delgoods_size";
        var goods_id="<?php echo $goodsid?>";
        $.post(url, { "sizeid": size_id, "goodsid": goods_id }, function (data) {
            var jsonData = $.parseJSON(data);
            if (jsonData.Statu == 'ok') {
                Success(jsonData)
            }
            else {
                Success(jsonData)
            }
        })
    }

</script>
<div id="dcMain" style="margin-left:0;padding-top:10px;">
    <div style="padding-left:22px;color:red;">注：选择即修改</div>
    <!-- 当前位置 -->
    <div id="manager" class="mainBox" style="padding-top:0;">
        <table width="100%" border="0" cellpadding="8" cellspacing="0" class="tableBasic">
            <tr>
                <th>选择</th>
                <th>尺码</th>
            </tr>
            <?php foreach($goodssizelist as $goodssizeItem):?>
            <tr>
                <td width="200" align="right"> <input ck="ck" id="size_<?php echo $goodssizeItem['sizeid']?>" type="checkbox" <?php echo $goodssizeItem['goods_size_id']>0?"checked='checked'":""?> value="<?php echo $goodssizeItem['sizeid']?>" /></td>
                <td>
                    <label for="size_<?php echo $goodssizeItem['sizeid']?>"><?php echo $goodssizeItem['title']?></label>
                </td>
            </tr>
            <?php endforeach;?>
        </table>
    </div>
</div>
